<?=$this->load->view('public/v_html')?>
<title><?=$this->_lang['geili']?></title>
<script type="text/javascript"
	src="<?=base_url ( '/js/jquery.masonry.min.js' )?>"></script>
<style>
/* tooltip */
#tooltip {
	position: fixed;
	border: 1px solid #ccc;
	background: #333;
	padding: 2px;
	display: none;
	color: #fff;
}

#page {
	margin: 0 auto;
}

.page {
	cursor: pointer;
}

.page:hover {
	border: 1px solid #999;
	padding: 0 1px 0 1px;
}

#main {
	background: #FFF;
	padding-left: 50px;
}

.item {
	border: 1px solid #EEE;
	float: left;
	padding: 10px;
	width: 260px;
	margin: 10px 0px 0 14px;
}

.item img {
	border: none;
	border: #F00 solid 1px;
}

.items:hover {
	border: #000 dashed 1px;
	padding:5px;
}

.tgms9 {
	color: black;
	font-size: 14px;
	font-weight: bold;
	line-height: 20px;
}

.tgms9 A {
	color: black
}

.tgms9 A:hover {
	color: black;
	text-decoration: none;
}

.pprice {
	width: 260px;
	height: 20px;
	background: #5A554F;
	filter: progid:DXImageTransform.Microsoft.Alpha(opacity=60 );
	-moz-opacity: 0.6;
	opacity: 0.6;
	position: relative;
	top: -20px;
	color: #FFF;
}

.pprice .left {
	margin-left: 20px;
}

.pprice .right {
	margin-left: 40px;
}

.tbk0 {
	cursor: pointer;
	background: url(<?=base_url('images/xxd.png')?>) no-repeat 0 0;
	height: 48px;
	margin: 0 auto auto auto;
	position: relative;
	top: -20px;
	display: block;
}

.tgms16 {
	height: 18px;
	line-height: 18px;
	font-size: 12px;
	font-weight: bold;
	color: #F5D09A;
}

.tgms16 div {
	float: left;
}

.deldiv {
	margin-left: 7px
}

.spandiv {
	margin-left: 7px;
}

.nav {
	border: #09FF09 solid 1px;
}

.tgms19 {
	width: 160px;
	height: 30px;
	float: left;
	font-weight: bold;
	line-height: 30px;
	font-family: 微软雅黑;
	font-size: 28px;
	color: white;
}

b {
	height: 32px;
	width: 86px;
	background: url(<?= base_url('images/xxd.png')?>)
		no-repeat 0 -456px;
	display: block;
	cursor: pointer;
	position: absolute;
	left: 160px;
	top: 15px;
}

.buy-action:hover {
	text-decoration: none;
	color: white;
}

.price {
	float: left;
	color: white;
	font: bold 24px "Arial";
	letter-spacing: -2px;
	text-shadow: 0 0 0 transparent, 1px 1px 1px #8A181B;
}

.tiel {
	width: 260px;
}

#loading {
	color: #fff;
	text-align: center;
	padding-top: 15px;
	height: 50px;
	width: 200px;
	filter: alpha(Opacity =         80);
	-moz-opacity: 0.5;
	opacity: 0.5;
	z-index: 100;
	margin: auto;
	background-color: #554646;
	display: none;
	position: relative;
	top: -190px;
}
</style>
<script language="javascript">
var title;
function falls(){    //瀑布流
	var $container = $('#main');
    $container.imagesLoaded( function(){
      $container.masonry({
        itemSelector : '.item'
      });
    });
}
function falls_des(){
	var $container = $('#main');
	$container.masonry( 'destroy' )
}

$(document).ready(function (){
	 $(".prepages").live("click",function(){
		 $(window).scrollTop(0, 0);  
	 })
	
	$("a[name=get_goods]").click(function (){
	$("#get_shop").html("<img src='<?=base_url('images/loading.gif') ?>'/>");
	$.ajax({
		type:'POST',
		datatype:'html',
		url:'<?=base_url('index.php/tbk/get_goods')?>',
		data:{"search":$("input[name=search]").val()},
		success:function (result){
			eval("var ret = "+result);
			if(ret.error == 1){
				alert(ret.msg);
				$("#get_shop").html('');
			}
			else{
				$("#get_shop").html(ret.html);
			}
		}
		})	
	})
	
})

$(document).ready(function (){

	$("a[name=get_shops]").click(function (){
	$("#get_shop").html("<img src='<?=base_url('images/loading.gif') ?>'/>");
	$.ajax({
		type:'POST',
		datatype:'html',
		url:"<?=base_url('index.php/tbk/shop_search')?>",
		data:{"shop":$("input[name=shop]").val()},
		success:function (result){
			eval("var ret = "+result);
			if(ret.error==1)
			{
				alert(ret.msg);
				$("#get_shop").html('');
			}
			else{
				$("#get_shop").html(ret.html);
			}	
		}
		})	
	})
})
var f=0;
window.onscroll=function(){
	var a = document.documentElement.scrollTop==0? document.body.clientHeight : document.documentElement.clientHeight;
	var b = document.documentElement.scrollTop==0? document.body.scrollTop : document.documentElement.scrollTop;
	var c = document.documentElement.scrollTop==0? document.body.scrollHeight : document.documentElement.scrollHeight;

	if(a+b==c){
		if(f == 0){
		f = 1;
		$("#loading").show();
		name = $("#title").html();
		pagenos= $("#pageno").html();
		$.ajax({
			type:'POST',
			async:false,
			url:"<?=site_url('tbk/search')?>",
			data:{"name":name,"pageno":pagenos,"f":"2"},
			success:function (result){
				eval("var res = "+result);
				f = 0;
				if(res.error==0){
					$("#pageno").text(res.pageno);
					ids = "item"+pagenos;
					st = "<div id="+ids+">"+res.html+"</div>";
					$add = $(st);
					if(navigator.userAgent.indexOf("MSIE")>0) {    
						$('#main').append( $add ).masonry( 'appended', $add );      //IE浏览器  
						setTimeout("loadImage('"+ids+"')",1000);
					}else{
						setTimeout("$('#main').append( $add ).masonry( 'appended', $add );loadImage('"+ids+"');",1000);
					}
				}else{
					 goods('热卖',1);				
				}
			}
		})
		}
	}
}

function add_fav(){
	var d= document.location.href;
	var c="<?=$this->_lang['geili']?>";
	if(document.all){
		window.external.AddFavorite(d,c);
	}else{
		if(window.sidebar){window.sidebar.addPanel(c,d,"");}else{alert("<?=$this->_lang['add_fav_error']?>");}
	}
}

function goods(title,pageno){
	$("#contents").html("<img src='<?=base_url('images/loading.gif') ?>'/>");
	falls_des();
	$.ajax({
		type:'POST',
		url:"<?=site_url('tbk/search')?>",
		data:{"name":title,"pageno":pageno},
		success:function (result){
			eval("var res = "+result);
			if(res.error==0){
				$(".item").not($("#navs")[0]).remove();
				$("#contents").html(res.html);
				setTimeout(falls,1 );
				$("#pagg").show();
				$("#title").text(title);
				$("#prepage").html(res.prepage);
				$("#pageno").text(res.pageno);
				$("#next").html(res.nextpage);
				loadImage("contents");
			}else{
				 goods('热卖',1);				
			}
		}
	})
}
</script>
<script type="text/javascript">
alimama_pid="mm_17750613_3303167_10764668";
alimama_width=200;
alimama_height=200;
alimama_displaytype= "c";
</script>
<script src="http://a.alimama.cn/inf.js" type="text/javascript"></script>
</head>
<body>
<?php
$lang ["modle"] = $modle;
if (isset ( $usermail )) :
	$lang ["usermail"] = $usermail;
	?>
<?=$this->load->view('public/v_header',$lang)?>
<?php else: ?>
<?=$this->load->view('public/v_header',$lang)?>
<?php endif; ?>
<div style="display: none">
		<span id="title"><?=$title ?></span> <span id="pageno">2</span>
	</div>
	<div id="body-wrapper">
		<div id="main-content">
			<div class="clear"></div>
			<div class="content-box" align="center">
				<div class="content-box-header" align="left">
					<h3><?=$this->_lang['geili']?><a onclick="add_fav();"><?=$this->_lang['add_fav']?></a>
					</h3>
					&nbsp;
					<h3><?=$this->_lang['QQ']?></h3>
					&nbsp;
					<h3><?=$this->_lang['union_login'] ?></h3>
					<a href="<?=site_url('login/qq')?>"><img
						src="<?=base_url('images/qq.png')?>" /></a> <a
						href="<?=site_url('login/sina')?>"><img
						src="<?=base_url('images/sina.png')?>" /></a> <a
						href="<?=site_url('login/neteasy')?>"><img
						src="<?=base_url('images/163.png')?>" /></a>
						<script type="text/javascript">
															(function(){
															var p = {
															url:location.href,
															showcount:'1',/*是否显示分享总数,显示：'1'，不显示：'0' */
															desc:'给力网是一个专业的淘宝购物返利网站,好用,简单,不掉一笔单,绝对是居家购物必备网站',/*默认分享理由(可选)*/
															summary:'给力网是一个专业的淘宝购物返利网站,好用,简单,不掉一笔单,绝对是居家购物必备网站',/*分享摘要(可选)*/
															title:'给力网',/*分享标题(可选)*/
															site:'给力网',/*分享来源 如：腾讯网(可选)*/
															pics:'http://www.geili0574.com/images/logo/logo2.png', /*分享图片的路径(可选)*/
															style:'103',
															width:135,
															height:20
															};
															var s = [];
															for(var i in p){
															s.push(i + '=' + encodeURIComponent(p[i]||''));
															}
															document.write(['<a version="1.0" class="qzOpenerDiv" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?',s.join('&'),'" target="_blank">分享</a>'].join(''));
															})();
															</script>
															<script src="http://qzonestyle.gtimg.cn/qzone/app/qzlike/qzopensl.js#jsdate=20111201" charset="utf-8"></script>
															
															<iframe width="63" height="24" frameborder="0" allowtransparency="true" marginwidth="0" marginheight="0" scrolling="no" border="0" src="http://widget.weibo.com/relationship/followbutton.php?language=zh_cn&width=63&height=24&uid=1707534817&style=1&btn=red&dpc=1"></iframe>
															
					<div class="clear"></div>

				</div>
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab4">
						<br />
						<form>
							<div align="center">
								<p>
									<input type="text" class="text-input small-input" name="search"
										id="search_good"
										onblur="if(this.value==''){this.value='<?=$this->_lang['search']?>'};"
										value="<?=$this->_lang['search']?>"
										onclick="if(this.value=='<?=$this->_lang['search']?>'){this.value=''}"></input>
									<a class="button" name="get_goods"><?=$this->_lang['tbk_search']?></a>&nbsp;
									<input type="text" class="text-input small-input" name="shop"
										id="search_shop"
										onblur="if(this.value==''){this.value='<?=$this->_lang['search_shop']?>' };"
										value="<?=$this->_lang['search_shop']?>"
										onclick="if(this.value=='<?=$this->_lang['search_shop']?>'){this.value=''}"></input>
									<a class="button" name="get_shops"><?=$this->_lang['tbk_shop']?></a>
								</p>
							</div>
							<br />
							<div id="get_shop"></div>
							<div id="get_info" align="left">
								<div id="page">
									<div id="main">
										<div class="item nav" id="navs">
											<div class="sub-tag">
												<div class="sub-tag-list"
													style="position: relative; padding-top: 10px">
												<?php foreach ($nav as $v) : ?>
													<h3><?=$v->name ?></h3>
													<dl>
														<?php foreach ($v->c_nav as $vv):?>
														<dt>
															<a onclick="goods('<?=$vv->name ?>',1)"><?=$vv->name ?></a>
														</dt>
														<?php endforeach;?>
													</dl>
												<?php endforeach;?>
												</div>
											</div>
										</div>
										<!-- asdf^^^^^^^^^^^^^^^^^^ -->
										<div id="contents">
										<?php foreach ($goods_hot as $v):?>
										<div class="item items">
												<div class="tgms9 tiel">
													<a href="<?=$v['click_url'] ?>" target="_blank"
														class="thickbox" title="<?=$v['title'] ?>">
												<?=$v['title']?>
												</a>
												</div>
												<a href="<?=$v['click_url'] ?>" target="_blank"> <img
													width="260" src="<?=$v['pic_url'] ?>_60x60.jpg" /></a>
												<div class="pprice">
													<span class="left">已售<em><?=$v['volume'] ?></em></span><span
														class="right">返利<em><?=round($v['coupon_price']*$v['commission_rate']*0.00005,2) ?></em></span>
												</div>
												<div class="tbk0">
													<div class="tgms16">
														<div class="deldiv">
															<del><?=$v['price'] ?>元</del>
														</div>
														<div class="spandiv">
															<span>结束时间: <?=$v['coupon_end_time'] ?></span>
														</div>
														<div class="clear"></div>
														<a href="<?=$v['click_url'] ?>" target="_blank"> <span
															class="price">￥<em><?=$v['coupon_price'] ?></em></span> <b
															class="btn"></b></a>
															<script type="text/javascript">
															(function(){
															var p = {
															url:'<?=$v['click_url']?>',
															showcount:'0',/*是否显示分享总数,显示：'1'，不显示：'0' */
															desc:'<?=($v['title'])?>',/*默认分享理由(可选)*/
															summary:'给力网(http://www.geili0574.com)是一个专业的淘宝购物导购类网站,好用,简单,不掉一笔单,绝对是居家购物必备网站',/*分享摘要(可选)*/
															title:'点击看详情',/*分享标题(可选)*/
															site:'给力网',/*分享来源 如：腾讯网(可选)*/
															pics:'<?=$v['pic_url']?>', /*分享图片的路径(可选)*/
															style:'103',
															width:135,
															height:20
															};
															var s = [];
															for(var i in p){
															s.push(i + '=' + encodeURIComponent(p[i]||''));
															}
															document.write(['<a version="1.0" class="qzOpenerDiv" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?',s.join('&'),'" target="_blank">分享</a>'].join(''));
															})();
															</script>
															<script src="http://qzonestyle.gtimg.cn/qzone/app/qzlike/qzopensl.js#jsdate=20111201" charset="utf-8"></script>
															
															<script type="text/javascript" charset="utf-8">
															(function(){
															  var _w = 86 , _h = 50;
															  var param = {
															    url:'<?=$v['click_url']?>',
															    type:'6',
															    count:'0', /**是否显示分享数，1显示(可选)*/
															    appkey:'3682749135', /**您申请的应用appkey,显示分享来源(可选)*/
															    title:'<?=($v['title'])?>', /**分享的文字内容(可选，默认为所在页面的title)*/
															    pic:'<?=$v['pic_url']?>', /**分享图片的路径(可选)*/
															    ralateUid:'', /**关联用户的UID，分享微博会@该用户(可选)*/
																language:'zh_cn', /**设置语言，zh_cn|zh_tw(可选)*/
															    rnd:new Date().valueOf()
															  }
															  var temp = [];
															  for( var p in param ){
															    temp.push(p + '=' + encodeURIComponent( param[p] || '' ) )
															  }
															  document.write('<iframe allowTransparency="true" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?' + temp.join('&') + '" width="'+ _w+'" height="'+_h+'"></iframe>')
															})()
															</script>
														<div class="clear"></div>
													</div>
												</div>
											</div>
										<?php endforeach;?>
										</div>
										<!-- end^^^^^^^^^^^^^^^^^^^ -->
									</div>
									<nav id="page-nav">
										<a href=""></a>
									</nav>
									<div class="clear"></div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
			<!-- End #tab1 -->
			<div class="clear"></div>
			<div>
				<!--友情链接:<br/> <a href="http://zhaizhaixiaofu.taobao.com/" target="_blank"><img src="<?=base_url('images/link/link.jpg') ?>" /></a>-->
				友情链接:<a href="http://zhaizhaixiaofu.taobao.com/" target="_blank">宅宅小腐</a><a href="http://shop72378625.taobao.com/" target="_blank">小璐小A的珠宝店</a>
			</div>
			<div id="footer">
				<small> <?=$this->_lang['copy_right']?> | Powered by <a
					href="http://www.geili0574.com">TBCOM</a> | <a href="#">Top</a>
				</small>
			</div>
		</div>
	</div>
	<div id="loading">
		<p>正在为你加载……</p>
		<img src="<?=base_url('images/loading/psb.gif') ?>" />
	</div>

	<script src="<?=base_url('js/jquery.infinitescroll.min.js') ?>"></script>
	<script type="text/javascript">
	$(function (){
		var $container = $('#main');
	    $container.imagesLoaded( function(){
	      $container.masonry({
	        itemSelector : '.item'
	      });
	    });

	    $container.infinitescroll({
	        navSelector  : '#page-nav',    // selector for the paged navigation 
	        nextSelector : '#page-nav a',  // selector for the NEXT link (to page 2)
	        itemSelector : '.item',     // selector for all items you'll retrieve
	        loading: {
	            finishedMsg: '没有更多图片。',
	            img: '<?=base_url('images/loading/psb.gif') ?>'
	          }
	        },
	        // trigger Masonry as a callback
	        function( newElements ) {
	          // hide new items while they are loading
	          var $newElems = $( newElements ).css({ opacity: 0 });
	          // ensure that images load before adding to masonry layout
	          $newElems.imagesLoaded(function(){
	            // show elems now they're ready
	            $newElems.animate({ opacity: 1 });
	            $container.masonry( 'appended', $newElems, true ); 
	          });
	        }
	      );
	    
	});
	</script>
	<script language="javascript">
$("#search_good").keydown(function (e){
	if(e.keyCode == 13){
		$("#get_info").html("<img src='<?=base_url('images/loading.gif') ?>'/>");
		$.ajax({
			type:'POST',
			datatype:'json',
			url:"<?=base_url('index.php/tbk/get_goods')?>",
			data:{"search":$("input[name=search]").val()},
			success:function (result){
				eval("var ret = "+result);
				if(ret.error==1)
				{
					alert(ret.msg);
					$("#get_info").html('');
				}
				else{
					$("#get_info").html(ret.html);
					
				}	
			}
			})
		}
	});

	$("#search_shop").keydown(function (e){
	if(e.keyCode == 13){
		$("#get_shop").html("<img src='<?=base_url('images/loading.gif') ?>'/>");
		$.ajax({
			type:'POST',
			datatype:'json',
			url:"<?=base_url('index.php/tbk/shop_search')?>",
			data:{"shop":$("input[name=shop]").val()},
			success:function (result){
				eval("var ret = "+result);
				if(ret.error==1){
					alert(ret.msg);
					$("#get_shop").html('');
				}
				else{
					$("#get_shop").html(ret.html);
				}	
			}
		})
	}
});
	function loadImage(idv_v){
		$("#"+idv_v+" img").each(function(e, f) {
			var img = new Image();
			var b = $(this);
			var src = b.attr("src");
			src = src.replace("_60x60.jpg","_240x240.jpg"); 
			img.src = src;
			//img.onload = function() {
			b.attr("src",src);
			//}
		})
	}
	loadImage("contents");
</script>
</body>
</html>
